import Vue    from 'vue'
import Vuex   from 'vuex'
import modules from '@/module'
import router,{bindStore}    from '@/router'
import { sync }              from 'vuex-router-sync'

Vue.use(Vuex)
let defaultState = {};
const store = new Vuex.Store({
	modules,
	mutations:{
		reset(state){
			 let s = JSON.parse(JSON.stringify(defaultState));
			 s.router = state.router;
			this.replaceState(s);
		}
	}
});
sync(store, router, { moduleName: 'router' } )
bindStore(store);

defaultState = JSON.parse(JSON.stringify(store.state));

export default store;